update of lb() and ub() during search?

28 views
Skip to first unread message

Laura Climent

unread,
Mar 13, 2025, 4:17:56 AMMar 13
to MiniZinc
Hi all,

I want to update a variable if during search the lb of another variable
becomes higher than certain value. I tried this:

constraint if lb(x) > 15 then y=1 else y=0 endif;


but I am afraid that the lb is not getting updated during search and it has
the same value during all the search. Therefore, I assume that the lb(x) is always
the minimum domain of x, even after the pruning of its domain during the
propagation.

Am I right? Do you know another way of doing what I want (checking the lower
bound during the search and propagation and including it in a constraint)

Best regards,
Laura

guido.tack

unread,
Mar 13, 2025, 4:27:39 AMMar 13
to MiniZinc
Hi,

The lb and ub functions can't be used in this way, unfortunately. They are only guaranteed to return some valid lower (or upper) bound at the time when the model is translated to FlatZinc, and the MiniZinc to FlatZinc translation replaces the function call with the concrete value at that time. So the solver doesn't ever see these functions, which means that it can't evaluate them during the search.
The best way (I've found) to think about these functions is that you need to be able to replace them with just their argument, and for any solution, the constraint still has to hold. So in your case, the use of lb would only be correct if "if x > 15 then y=1 else y=0 endif" is a correct constraint for the problem you're modelling.

It looks like what you would like to implement is a propagation algorithm for a particular constraint (probably based on a set of rules). You will need to implement those algorithms directly for the underlying solver (and then make them accessible from MiniZinc), or reformulate your constraints in terms of constraints that MiniZinc already supports.

Cheers,
Guido

Laura Climent

unread,
Mar 14, 2025, 5:41:22 AMMar 14
to mini...@googlegroups.com
Thanks a million Guido. 
What you told me is what I suspected, but I wanted to be sure that there was not another way of solving it without requiring a specific implementation for each solver. 

Best regards, 
Laura

--
You received this message because you are subscribed to the Google Groups "MiniZinc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to minizinc+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/minizinc/05291cb6-31e3-4ba9-ac9b-d4cb3848fc42n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages